<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>

        <ui:composition template="./potentialCustomers.xhtml">

            <ui:define name="tabContent">
                <h:form>
                    <p:panel>
                        <h:panelGrid columns="2">
                            Đầu số* 
                            <h:selectManyMenu value="#{tblRawMoBean.selectedShortCodes}" style="width: 150px; height: 200px;">
                                <f:selectItems value="#{tblRawMoBean.shortCodeMap}"/>
                            </h:selectManyMenu>

                            Danh sách nội dung
                            <p:inputTextarea value="#{tblRawMoBean.syntaxString}"/>

                            Ngày
                            <p:inputText id="dayStringSyntax" value="#{tblRawMoBean.days}" style="width: 300px"/>

                            <h:outputText/>
                            <p:commandButton value="Tìm kiếm" action="#{tblRawMoBean.findContentStatistic()}" oncomplete="processingDialog.hide()"
                                             onclick="processingDialog.show()" ajax="false"/>


                        </h:panelGrid>
                    </p:panel>
                </h:form>

                <br/>
                <h:form id="tblRawMoTableForm">
                    <p:dataTable id="rawMoTable" value="#{tblRawMoBean.moStatistics}" var="moItem" paginator="#{tblRawMoBean.moStatistics.size() >100}" rows="100"
                                 >

                        <p:column headerText="Đầu số" sortBy="#{moItem.shortCode}">
                            #{moItem.shortCode}
                        </p:column>
                        <p:column headerText="Nội dung MT" sortBy="#{moItem.content}">
                            #{moItem.content}
                        </p:column>
                        <p:column headerText="Số lượng" sortBy="#{moItem.count}">
                            <p:commandLink action="#{tblRawMoBean.findSubscriberList(moItem.content, moItem.shortCode)}" value="#{moItem.count}" 
                                           update="tblRawMoTableForm:mdnTextArea" onsuccess="subscriberDialog.show();"/>

                        </p:column>
                    </p:dataTable>

                    <p:dialog id="subscriberDiag" width="200" hideEffect="explode" widgetVar="subscriberDialog" 
                              modal="true" header="Danh sách khách hàng" >  
                        <b>
                            <h:outputText value="Danh sách khách hàng"/>
                        </b>
                        <br/>

                        <p:scrollPanel> 
                            <p:inputTextarea id="mdnTextArea" value="#{tblRawMoBean.mdnListString}" />
                        </p:scrollPanel>

                        <p:commandButton value="Đóng" onclick="subscriberDialog.hide()" type="button" />   

                    </p:dialog> 
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
